Changeset: 6a9d65d08b45 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6a9d65d08b45
Modified Files:
monetdb5/extras/pyapi/formatinput.c
monetdb5/extras/pyapi/pyapi.c
monetdb5/extras/pyapi/type_conversion.c
monetdb5/extras/pyapi/type_conversion.h
monetdb5/extras/pyapi/unspecified_evil.h
Branch: pythonudf
Log Message:
Fixes for Windows compilation.
Change some int variables to size_t.
Remove stdbool reference.
Remove references to MMAP operations on Windows, because we don't support MMAP
on Windows.
diffs (118 lines):
diff --git a/monetdb5/extras/pyapi/formatinput.c
b/monetdb5/extras/pyapi/formatinput.c
--- a/monetdb5/extras/pyapi/formatinput.c
+++ b/monetdb5/extras/pyapi/formatinput.c
@@ -326,12 +326,12 @@ char* FormatCode(char* code, char **args
} else if (code[i] == '\t') {
initial_spaces += tabwidth;
} else {
- // Statement starts here
- seen_statement = true;
// Look through the indentation_levels array to find the level
of the statement
// from the amount of initial spaces
bool placed = false;
- int level = 0;
+ size_t level = 0;
+ // Statement starts here
+ seen_statement = true;
for(j = 0; j < indentation_count; j++) {
if (initial_spaces == indentation_levels[j]) {
level = j;
diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c
--- a/monetdb5/extras/pyapi/pyapi.c
+++ b/monetdb5/extras/pyapi/pyapi.c
@@ -127,6 +127,7 @@ static bool python_call_active = false;
// This #define creates a new BAT with the internal data and mask from a Numpy
array, without copying the data
// 'bat' is a BAT* pointer, which will contain the new BAT. TYPE_'mtpe' is the
BAT type, and 'batstore' is the heap storage type of the BAT (this should be
STORE_CMEM or STORE_SHARED)
+#ifdef HAVE_FORK
#define CREATE_BAT_ZEROCOPY(bat, mtpe, batstore) {
\
bat = BATnew(TYPE_void, TYPE_##mtpe, 0, TRANSIENT);
\
BATseqbase(bat, seqbase); bat->T->nil = 0; bat->T->nonil = 1;
\
@@ -170,6 +171,44 @@ static bool python_call_active = false;
/*Take over the data from the numpy array*/
\
if (ret->numpy_array != NULL)
PyArray_CLEARFLAGS((PyArrayObject*)ret->numpy_array, NPY_ARRAY_OWNDATA);
\
}
+#else
+#define CREATE_BAT_ZEROCOPY(bat, mtpe, batstore) {
\
+ bat = BATnew(TYPE_void, TYPE_##mtpe, 0, TRANSIENT);
\
+ BATseqbase(bat, seqbase); bat->T->nil = 0; bat->T->nonil = 1;
\
+ bat->tkey = 0; bat->tsorted = 0; bat->trevsorted = 0;
\
+ /*Change nil values to the proper values, if they exist*/
\
+ if (mask != NULL)
\
+ {
\
+ for (iu = 0; iu < ret->count; iu++)
\
+ {
\
+ if (mask[index_offset * ret->count + iu] == TRUE)
\
+ {
\
+ (*(mtpe*)(&data[(index_offset * ret->count + iu) *
ret->memory_size])) = mtpe##_nil; \
+ bat->T->nil = 1;
\
+ }
\
+ }
\
+ }
\
+ bat->T->nonil = 1 - bat->T->nil;
\
+ /*When we create a BAT a small part of memory is allocated, free it*/
\
+ GDKfree(bat->T->heap.base);
\
+ bat->T->heap.base = &data[(index_offset * ret->count) *
ret->memory_size]; \
+ bat->T->heap.size = ret->count * ret->memory_size;
\
+ bat->T->heap.free = bat->T->heap.size; /*There are no free places in
the array*/ \
+ /*If index_offset > 0, we are mapping part of a multidimensional
array.*/ \
+ /*The entire array will be cleared when the part with index_offset=0
is freed*/ \
+ /*So we set this part of the mapping to 'NOWN'*/
\
+ if (index_offset > 0) bat->T->heap.storage = STORE_NOWN;
\
+ else {
\
+ bat->T->heap.storage = batstore;
\
+ }
\
+ bat->T->heap.newstorage = STORE_MEM;
\
+ bat->S->count = ret->count;
\
+ bat->S->capacity = ret->count;
\
+ bat->S->copiedtodisk = false;
\
+ /*Take over the data from the numpy array*/
\
+ if (ret->numpy_array != NULL)
PyArray_CLEARFLAGS((PyArrayObject*)ret->numpy_array, NPY_ARRAY_OWNDATA);
\
+ }
+#endif
// This #define converts a Numpy Array to a BAT by copying the internal data
to the BAT. It assumes the BAT 'bat' is already created with the proper size.
// This should only be used with integer data that can be cast. It assumes the
Numpy Array has an internal array of type 'mtpe_from', and the BAT has an
internal array of type 'mtpe_to'.
diff --git a/monetdb5/extras/pyapi/type_conversion.c
b/monetdb5/extras/pyapi/type_conversion.c
--- a/monetdb5/extras/pyapi/type_conversion.c
+++ b/monetdb5/extras/pyapi/type_conversion.c
@@ -99,7 +99,7 @@ bool pyobject_to_##type(PyObject **pyobj
PyLongObject *p = (PyLongObject*) ptr;
\
inttpe h = 0;
\
inttpe prev = 0;
\
- int i = Py_SIZE(p);
\
+ size_t i = Py_SIZE(p);
\
int sign = i < 0 ? -1 : 1;
\
i *= sign;
\
while (--i >= 0) {
\
@@ -130,7 +130,7 @@ bool pyobject_to_##type(PyObject **pyobj
#define CONVERSION_FUNCTION_FACTORY(tpe, inttpe) \
bool str_to_##tpe(char *ptr, size_t maxsize, tpe *value) \
{ \
- int i = maxsize - 1; \
+ size_t i = maxsize - 1; \
tpe factor = 1; \
if (i < 0) i = strlen(ptr) - 1; \
*value = 0; \
diff --git a/monetdb5/extras/pyapi/type_conversion.h
b/monetdb5/extras/pyapi/type_conversion.h
--- a/monetdb5/extras/pyapi/type_conversion.h
+++ b/monetdb5/extras/pyapi/type_conversion.h
@@ -15,7 +15,6 @@
#define _TYPE_CONVERSION_
#include <stdint.h>
-#include <stdbool.h>
#include <stddef.h>
#include "pyapi.h"
diff --git a/monetdb5/extras/pyapi/unspecified_evil.h
b/monetdb5/extras/pyapi/unspecified_evil.h
--- a/monetdb5/extras/pyapi/unspecified_evil.h
+++ b/monetdb5/extras/pyapi/unspecified_evil.h
@@ -16,6 +16,6 @@
#undef ssize_t
-typedef unsigned char bool;
+#define bool unsigned char
#endif
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list