Changeset: 6da89ff398dc for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6da89ff398dc
Added Files:
        sql/backends/monet5/Tests/pyapi28.sql
        sql/backends/monet5/Tests/pyapi28.stable.err
        sql/backends/monet5/Tests/pyapi28.stable.out
Modified Files:
        monetdb5/extras/pyapi/pyapi.c
Branch: pythonudf
Log Message:

Added test for duplicate elimination and fixed reference counting.


diffs (180 lines):

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
@@ -1912,7 +1912,8 @@ PyObject *PyArrayObject_FromBAT(PyInput 
                                     msg = createException(MAL, "pyapi.eval", 
"Failed to create string.");
                                     goto wrapup;
                                 }
-
+                            } else {
+                                Py_INCREF(pyptrs[offset]);
                             }
                             data[j++] = pyptrs[offset];
                         }
@@ -1949,6 +1950,8 @@ PyObject *PyArrayObject_FromBAT(PyInput 
                             ptrdiff_t offset = t - b->T->vheap->base;
                             if (!pyptrs[offset]) {
                                 pyptrs[offset] = PyString_FromString(t);
+                            } else {
+                                Py_INCREF(pyptrs[offset]);
                             }
                             data[j++] = pyptrs[offset];
                         }
diff --git a/sql/backends/monet5/Tests/pyapi28.sql 
b/sql/backends/monet5/Tests/pyapi28.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi28.sql
@@ -0,0 +1,17 @@
+
+START TRANSACTION;
+
+CREATE FUNCTION duplicate_strings() RETURNS TABLE(s STRING)  LANGUAGE PYTHON {
+    return numpy.repeat('hello', 1000000)
+};
+
+CREATE FUNCTION test_duplicates(s STRING) RETURNS BOOLEAN LANGUAGE PYTHON {
+    print(s)
+    del s
+    return True  
+};
+
+SELECT test_duplicates(s) FROM duplicate_strings();
+
+
+ROLLBACK;
diff --git a/sql/backends/monet5/Tests/pyapi28.stable.err 
b/sql/backends/monet5/Tests/pyapi28.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi28.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'pyapi28` in directory 'sql/backends/monet5` itself:
+
+
+# 16:15:16 >  
+# 16:15:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39674" "--set" 
"mapi_usock=/var/tmp/mtest-30857/.s.monetdb.39674" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/export/scratch2/raasveld/build/var/MonetDB/mTests_sql_backends_monet5"
 "--set" "embedded_r=yes" "--set" "embedded_py=true"
+# 16:15:16 >  
+
+# builtin opt  gdk_dbpath = 
/export/scratch2/raasveld/build/var/monetdb5/dbfarm/demo
+# builtin opt  gdk_debug = 0
+# builtin opt  gdk_vmtrim = no
+# builtin opt  monet_prompt = >
+# builtin opt  monet_daemon = no
+# builtin opt  mapi_port = 50000
+# builtin opt  mapi_open = false
+# builtin opt  mapi_autosense = false
+# builtin opt  sql_optimizer = default_pipe
+# builtin opt  sql_debug = 0
+# cmdline opt  gdk_nr_threads = 0
+# cmdline opt  mapi_open = true
+# cmdline opt  mapi_port = 39674
+# cmdline opt  mapi_usock = /var/tmp/mtest-30857/.s.monetdb.39674
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/export/scratch2/raasveld/build/var/MonetDB/mTests_sql_backends_monet5
+# cmdline opt  embedded_r = yes
+# cmdline opt  embedded_py = true
+# cmdline opt  gdk_debug = 536870922
+
+# 16:15:17 >  
+# 16:15:17 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-30857" "--port=39674"
+# 16:15:17 >  
+
+
+# 16:15:17 >  
+# 16:15:17 >  "Done."
+# 16:15:17 >  
+
diff --git a/sql/backends/monet5/Tests/pyapi28.stable.out 
b/sql/backends/monet5/Tests/pyapi28.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/Tests/pyapi28.stable.out
@@ -0,0 +1,90 @@
+stdout of test 'pyapi28` in directory 'sql/backends/monet5` itself:
+
+
+# 16:15:16 >  
+# 16:15:16 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=39674" "--set" 
"mapi_usock=/var/tmp/mtest-30857/.s.monetdb.39674" "--set" "monet_prompt=" 
"--forcemito" 
"--dbpath=/export/scratch2/raasveld/build/var/MonetDB/mTests_sql_backends_monet5"
 "--set" "embedded_r=yes" "--set" "embedded_py=true"
+# 16:15:16 >  
+
+# MonetDB 5 server v11.22.0
+# This is an unreleased version
+# Serving database 'mTests_sql_backends_monet5', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit 
integers dynamically linked
+# Found 15.589 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2015 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://lyon.da.cwi.nl:39674/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-30857/.s.monetdb.39674
+# MonetDB/GIS module loaded
+# Start processing logs sql/sql_logs version 52200
+# Finished processing logs sql/sql_logs
+# MonetDB/SQL module loaded
+# MonetDB/Python module loaded
+# MonetDB/R   module loaded
+
+Ready.
+# SQL catalog created, loading sql scripts once
+# loading sql script: 09_like.sql
+# loading sql script: 10_math.sql
+# loading sql script: 11_times.sql
+# loading sql script: 12_url.sql
+# loading sql script: 13_date.sql
+# loading sql script: 14_inet.sql
+# loading sql script: 15_querylog.sql
+# loading sql script: 16_tracelog.sql
+# loading sql script: 17_temporal.sql
+# loading sql script: 20_vacuum.sql
+# loading sql script: 21_dependency_functions.sql
+# loading sql script: 22_clients.sql
+# loading sql script: 23_skyserver.sql
+# loading sql script: 24_zorder.sql
+# loading sql script: 25_debug.sql
+# loading sql script: 26_sysmon.sql
+# loading sql script: 27_rejects.sql
+# loading sql script: 39_analytics.sql
+# loading sql script: 39_analytics_hge.sql
+# loading sql script: 40_geom.sql
+# loading sql script: 40_json.sql
+# loading sql script: 40_json_hge.sql
+# loading sql script: 41_md5sum.sql
+# loading sql script: 45_uuid.sql
+# loading sql script: 46_gsl.sql
+# loading sql script: 46_profiler.sql
+# loading sql script: 51_sys_schema_extension.sql
+# loading sql script: 72_fits.sql
+# loading sql script: 74_netcdf.sql
+# loading sql script: 75_storagemodel.sql
+# loading sql script: 80_statistics.sql
+# loading sql script: 80_udf.sql
+# loading sql script: 80_udf_hge.sql
+# loading sql script: 85_bam.sql
+# loading sql script: 90_generator.sql
+# loading sql script: 90_generator_hge.sql
+# loading sql script: 99_system.sql
+['hello' 'hello' 'hello' ..., 'hello' 'hello' 'hello']
+
+# 16:15:17 >  
+# 16:15:17 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-30857" "--port=39674"
+# 16:15:17 >  
+
+#START TRANSACTION;
+#CREATE FUNCTION duplicate_strings() RETURNS TABLE(s STRING)  LANGUAGE PYTHON {
+#    return numpy.repeat('hello', 1000000)
+#};
+#CREATE FUNCTION test_duplicates(s STRING) RETURNS BOOLEAN LANGUAGE PYTHON {
+#    print(s)
+#    del s
+#    return True  
+#};
+#SELECT test_duplicates(s) FROM duplicate_strings();
+% .L # table_name
+% test_duplicates_s # name
+% boolean # type
+% 5 # length
+[ true ]
+#ROLLBACK;
+
+# 16:15:17 >  
+# 16:15:17 >  "Done."
+# 16:15:17 >  
+
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to