Changeset: 44f0306154a8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=44f0306154a8
Modified Files:
monetdb5/extras/rapi/rapi.c
monetdb5/extras/rapi/rapi.h
testing/Mtest.py.in
Branch: RIntegration
Log Message:
R API: API only enabled iff GDK environment variable 'embedded_r' is set to
'true' or 'yes'. Modified Mtest.py.in to set this variable iff ./configure
found R.
diffs (75 lines):
diff --git a/monetdb5/extras/rapi/rapi.c b/monetdb5/extras/rapi/rapi.c
--- a/monetdb5/extras/rapi/rapi.c
+++ b/monetdb5/extras/rapi/rapi.c
@@ -25,11 +25,11 @@
#include "mal.h"
#include "mal_stack.h"
#include "mal_linker.h"
+#include "gdk_utils.h"
#include "rapi.h"
// R headers
-
#define R_INTERFACE_PTRS 1
#define CSTACK_DEFNS 1
@@ -111,6 +111,12 @@
BATsettrivprop(b);\
}
+const char* rapi_enableflag = "embedded_r";
+
+int RAPIEnabled(void) {
+ return(GDKgetenv_istrue(rapi_enableflag) ||
GDKgetenv_isyes(rapi_enableflag));
+}
+
// The R-environment should be single threaded, calling for some protective
measures.
static MT_Lock rapiLock;
static int rapiInitialized = FALSE;
@@ -236,6 +242,10 @@ str RAPIparser(int *ret, str *rcall) {
ParseStatus status;
str msg = NULL;
+ if (!RAPIEnabled()) {
+ throw(MAL, "rapi.eval", "Embedded R has not been enabled. Start
server with --set %s=true",rapi_enableflag);
+ }
+
(void) ret;
(void) R_ParseVector(mkString(*rcall), INT_MAX, &status, R_NilValue);
if (status != PARSE_OK)
@@ -263,6 +273,10 @@ str RAPIeval(Client cntxt, MalBlkPtr mb,
BUN cnt;
int initstatus = 0;
+ if (!RAPIEnabled()) {
+ throw(MAL, "rapi.eval", "Embedded R has not been enabled. Start
server with --set %s=true",rapi_enableflag);
+ }
+
rcall = malloc(strlen(exprStr) + sizeof(argnames) + 100);
if (rcall == NULL) {
throw(MAL, "rapi.eval", MAL_MALLOC_FAIL);
diff --git a/monetdb5/extras/rapi/rapi.h b/monetdb5/extras/rapi/rapi.h
--- a/monetdb5/extras/rapi/rapi.h
+++ b/monetdb5/extras/rapi/rapi.h
@@ -46,5 +46,6 @@ rapi_export void writeConsoleEx(const ch
rapi_export void writeConsole(const char * buf, int buflen);
char* rtypename(int rtypeid);
+int RAPIEnabled(void);
#endif /* _RAPI_LIB_ */
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -2739,6 +2739,10 @@ def DoIt(env, SERVER, CALL, TST, EXT, PR
Srvr.extend(DBINIT)
Srvr.extend(PROLOGUE)
+ # enable r integration in server
+ if CONDITIONALS['HAVE_LIBR'] == '#':
+ Srvr.extend(['--set', 'embedded_r=yes'])
+
pSrvr, pSrvrTimer = LaunchIt(Srvr,
'\nio.printf("\\nReady.\\n");\n', SrvrOut, SrvrErr, TIMEOUT)
ln="dummy"
while 0 < len(ln) and ln[:6] != 'Ready.':
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list