Changeset: b7f5722c5a13 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b7f5722c5a13
Added Files:
        sql/backends/monet5/UDF/capi/Tests/capi12.sql
        sql/backends/monet5/UDF/capi/Tests/capi12.stable.err
        sql/backends/monet5/UDF/capi/Tests/capi12.stable.out
Modified Files:
        sql/backends/monet5/UDF/capi/Tests/All
        sql/backends/monet5/UDF/capi/capi.c
        sql/backends/monet5/UDF/capi/cheader.h
Branch: jitudf
Log Message:

OIDs.


diffs (252 lines):

diff --git a/sql/backends/monet5/UDF/capi/Tests/All 
b/sql/backends/monet5/UDF/capi/Tests/All
--- a/sql/backends/monet5/UDF/capi/Tests/All
+++ b/sql/backends/monet5/UDF/capi/Tests/All
@@ -11,3 +11,4 @@ capi08
 capi09
 capi10
 capi11
+capi12
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi12.sql 
b/sql/backends/monet5/UDF/capi/Tests/capi12.sql
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/UDF/capi/Tests/capi12.sql
@@ -0,0 +1,23 @@
+
+START TRANSACTION;
+
+# oids
+CREATE FUNCTION capi12(inp OID) RETURNS BOOLEAN LANGUAGE C {
+    result->initialize(result, inp.count);
+    for(size_t i = 0; i < inp.count; i++) {
+        if (inp.data[i] == inp.null_value) {
+            result->data[i] = 0;
+        } else {
+            result->data[i] = 1;
+        }
+    }
+};
+CREATE TABLE oids(i OID);
+INSERT INTO oids(i) VALUES (100), (NULL), (200);
+
+SELECT * FROM oids WHERE capi12(i);
+
+DROP FUNCTION capi12;
+DROP TABLE oids;
+
+ROLLBACK;
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi12.stable.err 
b/sql/backends/monet5/UDF/capi/Tests/capi12.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/UDF/capi/Tests/capi12.stable.err
@@ -0,0 +1,34 @@
+stderr of test 'capi12` in directory 'sql/backends/monet5/UDF/capi` itself:
+
+
+# 13:43:07 >  
+# 13:43:07 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=34982" "--set" 
"mapi_usock=/var/tmp/mtest-84742/.s.monetdb.34982" "--set" "monet_prompt=" 
"--forcemito" "--dbpath=NONE/var/MonetDB/mTests_sql_backends_monet5_UDF_capi"
+# 13:43:07 >  
+
+# builtin opt  gdk_dbpath = /Users/myth/opt/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 = 34982
+# cmdline opt  mapi_usock = /var/tmp/mtest-84742/.s.monetdb.34982
+# cmdline opt  monet_prompt = 
+# cmdline opt  gdk_dbpath = 
/Users/myth/opt/mTests/sql/backends/monet5/UDF/capi/NONE/var/MonetDB/mTests_sql_backends_monet5_UDF_capi
+# cmdline opt  gdk_debug = 536870922
+
+# 13:43:07 >  
+# 13:43:07 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-84742" "--port=34982"
+# 13:43:07 >  
+
+
+# 13:43:08 >  
+# 13:43:08 >  "Done."
+# 13:43:08 >  
+
diff --git a/sql/backends/monet5/UDF/capi/Tests/capi12.stable.out 
b/sql/backends/monet5/UDF/capi/Tests/capi12.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/backends/monet5/UDF/capi/Tests/capi12.stable.out
@@ -0,0 +1,90 @@
+stdout of test 'capi12` in directory 'sql/backends/monet5/UDF/capi` itself:
+
+
+# 13:43:07 >  
+# 13:43:07 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=34982" "--set" 
"mapi_usock=/var/tmp/mtest-84742/.s.monetdb.34982" "--set" "monet_prompt=" 
"--forcemito" "--dbpath=NONE/var/MonetDB/mTests_sql_backends_monet5_UDF_capi"
+# 13:43:07 >  
+
+# MonetDB 5 server v11.28.0
+# This is an unreleased version
+# Serving database 'mTests_sql_backends_monet5_UDF_capi', using 4 threads
+# Compiled for x86_64-apple-darwin15.6.0/64bit with 128bit integers
+# Found 8.000 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2017 MonetDB B.V., all rights reserved
+# Visit https://www.monetdb.org/ for further information
+# Listening for connection requests on 
mapi:monetdb://dhcp-21.eduroam.cwi.nl:34982/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-84742/.s.monetdb.34982
+# MonetDB/SQL 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: 18_index.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: 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_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_profiler.sql
+# loading sql script: 51_sys_schema_extension.sql
+# loading sql script: 60_wlcr.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: 90_generator.sql
+# loading sql script: 90_generator_hge.sql
+# loading sql script: 99_system.sql
+
+# 13:43:07 >  
+# 13:43:07 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-84742" "--port=34982"
+# 13:43:07 >  
+
+#START TRANSACTION;
+#CREATE FUNCTION capi12(inp OID) RETURNS BOOLEAN LANGUAGE C {
+#    result->initialize(result, inp.count);
+#    for(size_t i = 0; i < inp.count; i++) {
+#        if (inp.data[i] == inp.null_value) {
+#            result->data[i] = 0;
+#        } else {
+#            result->data[i] = 1;
+#        }
+#    }
+#};
+#CREATE TABLE oids(i OID);
+#INSERT INTO oids(i) VALUES (100), (NULL), (200);
+[ 3    ]
+#SELECT * FROM oids WHERE capi12(i);
+% sys.oids # table_name
+% i # name
+% oid # type
+% 5 # length
+[ 100@0        ]
+[ 200@0        ]
+#DROP FUNCTION capi12;
+#DROP TABLE oids;
+#ROLLBACK;
+
+# 13:43:08 >  
+# 13:43:08 >  "Done."
+# 13:43:08 >  
+
diff --git a/sql/backends/monet5/UDF/capi/capi.c 
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -247,6 +247,7 @@ GENERATE_BASE_FUNCTIONS(int, int);
 GENERATE_BASE_FUNCTIONS(lng, lng);
 GENERATE_BASE_FUNCTIONS(flt, flt);
 GENERATE_BASE_FUNCTIONS(dbl, dbl);
+GENERATE_BASE_FUNCTIONS(oid, oid);
 
 GENERATE_BASE_HEADERS(char *, str);
 GENERATE_BASE_HEADERS(cudf_data_date, date);
@@ -639,6 +640,7 @@ static str CUDFeval(Client cntxt, MalBlk
                ATTEMPT_TO_WRITE_TO_FILE(f, "typedef float flt;\n");
                ATTEMPT_TO_WRITE_TO_FILE(f, "typedef double dbl;\n");
                ATTEMPT_TO_WRITE_TO_FILE(f, "typedef char* str;\n");
+               ATTEMPT_TO_WRITE_TO_FILE(f, "typedef size_t oid;\n");
                // now we search exprStr for any preprocessor directives (#)
                // we move these to the top of the file
                // this allows the user to normally #include files
@@ -896,7 +898,7 @@ static str CUDFeval(Client cntxt, MalBlk
                        } else if (bat_type == TYPE_int) {
                                GENERATE_BAT_INPUT(input_bats[index], int);
                        } else if (bat_type == TYPE_oid) {
-                               assert(0);
+                               GENERATE_BAT_INPUT(input_bats[index], oid);
                        } else if (bat_type == TYPE_lng) {
                                GENERATE_BAT_INPUT(input_bats[index], lng);
                        } else if (bat_type == TYPE_flt) {
@@ -1075,7 +1077,7 @@ static str CUDFeval(Client cntxt, MalBlk
                } else if (bat_type == TYPE_int) {
                        GENERATE_BAT_OUTPUT(int);
                } else if (bat_type == TYPE_oid) {
-                       assert(0);
+                       GENERATE_BAT_OUTPUT(oid);
                } else if (bat_type == TYPE_lng) {
                        GENERATE_BAT_OUTPUT(lng);
                } else if (bat_type == TYPE_flt) {
@@ -1479,7 +1481,7 @@ static const char *GetTypeDefinition(int
        } else if (type == TYPE_int) {
                tpe = "int";
        } else if (type == TYPE_oid) {
-               assert(0);
+               tpe = "size_t";
        } else if (type == TYPE_lng) {
                tpe = "lng";
        } else if (type == TYPE_flt) {
@@ -1513,7 +1515,7 @@ static const char *GetTypeName(int type)
        } else if (type == TYPE_int) {
                tpe = "int";
        } else if (type == TYPE_oid) {
-               assert(0);
+               tpe = "oid";
        } else if (type == TYPE_lng) {
                tpe = "lng";
        } else if (type == TYPE_flt) {
@@ -1548,7 +1550,7 @@ void *GetTypeData(int type, void *struct
        } else if (type == TYPE_int) {
                data = ((struct cudf_data_struct_int *)struct_ptr)->data;
        } else if (type == TYPE_oid) {
-               assert(0);
+               data = ((struct cudf_data_struct_oid *)struct_ptr)->data;
        } else if (type == TYPE_lng) {
                data = ((struct cudf_data_struct_lng *)struct_ptr)->data;
        } else if (type == TYPE_flt) {
@@ -1582,7 +1584,7 @@ size_t GetTypeCount(int type, void *stru
        } else if (type == TYPE_int) {
                count = ((struct cudf_data_struct_int *)struct_ptr)->count;
        } else if (type == TYPE_oid) {
-               assert(0);
+               count = ((struct cudf_data_struct_oid *)struct_ptr)->count;
        } else if (type == TYPE_lng) {
                count = ((struct cudf_data_struct_lng *)struct_ptr)->count;
        } else if (type == TYPE_flt) {
diff --git a/sql/backends/monet5/UDF/capi/cheader.h 
b/sql/backends/monet5/UDF/capi/cheader.h
--- a/sql/backends/monet5/UDF/capi/cheader.h
+++ b/sql/backends/monet5/UDF/capi/cheader.h
@@ -46,4 +46,4 @@ DEFAULT_STRUCT_DEFINITION(cudf_data_date
 DEFAULT_STRUCT_DEFINITION(cudf_data_time, time);
 DEFAULT_STRUCT_DEFINITION(cudf_data_timestamp, timestamp);
 DEFAULT_STRUCT_DEFINITION(cudf_data_blob, blob);
-DEFAULT_STRUCT_DEFINITION(double, decimal);
+DEFAULT_STRUCT_DEFINITION(size_t, oid);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to