Changeset: b84adc3db61c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b84adc3db61c
Added Files:
clients/R/MonetDB.R/src/profiler-r.c
Modified Files:
clients/R/MonetDB.R/R/dbi.R
clients/R/MonetDB.R/src/profiler.c
sql/scripts/16_tracelog.sql
Branch: default
Log Message:
Progress Bar: Removed separate MAL connection and separated R parts
diffs (111 lines):
diff --git a/clients/R/MonetDB.R/R/dbi.R b/clients/R/MonetDB.R/R/dbi.R
--- a/clients/R/MonetDB.R/R/dbi.R
+++ b/clients/R/MonetDB.R/R/dbi.R
@@ -126,12 +126,8 @@ setMethod("dbConnect", "MonetDBDriver",
dbSendQuery(conn, "set optimizer='sequential_pipe'")
}
- # enable profiler, we use a MAL connection for this
if (getOption("monetdb.profile", T)) {
- msocket <- .mapiConnect(host, port, timeout)
- .mapiAuthenticate(msocket, dbname, user, password, language="mal")
- .profiler_enable(msocket)
- .mapiDisconnect(msocket);
+ .profiler_enable(conn)
}
return(conn)
diff --git a/clients/R/MonetDB.R/src/profiler-r.c
b/clients/R/MonetDB.R/src/profiler-r.c
new file mode 100644
--- /dev/null
+++ b/clients/R/MonetDB.R/src/profiler-r.c
@@ -0,0 +1,11 @@
+#include <R.h>
+#include <Rdefines.h>
+
+int profiler_start();
+
+SEXP profiler_start_listen() {
+ SEXP port;
+ port = NEW_INTEGER(1);
+ INTEGER_POINTER(port)[0] = profiler_start();
+ return port;
+}
diff --git a/clients/R/MonetDB.R/src/profiler.c
b/clients/R/MonetDB.R/src/profiler.c
--- a/clients/R/MonetDB.R/src/profiler.c
+++ b/clients/R/MonetDB.R/src/profiler.c
@@ -7,14 +7,13 @@
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
+#include <math.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/time.h>
-#include <R.h>
-#include <Rdefines.h>
-
#ifdef __WIN32__
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -243,13 +242,11 @@ void profiler_arm() {
profiler_armed = 1;
}
-SEXP profiler_start_listen() {
- SEXP port;
-
+int profiler_start() {
profiler_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(profiler_socket < 0) {
- error("socket error\n");
- return R_NilValue;
+ fprintf(stderr, "socket error\n");
+ return -1;
}
struct sockaddr_in serv_addr;
@@ -262,16 +259,11 @@ SEXP profiler_start_listen() {
if (bind(profiler_socket, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0 ||
getsockname(profiler_socket, (struct sockaddr *)&serv_addr,
&len) < 0) {
- error("could not bind to process (%d) %s\n", errno, strerror(errno));
- return R_NilValue;
+ fprintf(stderr, "could not bind to process (%d) %s\n", errno,
strerror(errno));
+ return -1;
}
- // start backgroud listening thread
- pthread_create(&profiler_pthread, NULL, profiler_thread, NULL);
- port = NEW_INTEGER(1);
- INTEGER_POINTER(port)[0] = ntohs(serv_addr.sin_port);
-
- // some nicer characters for UTF-enabled terminals
+ // some nicer characters for UTF-enabled terminals
char* ctype = getenv("LC_CTYPE");
strupp(ctype);
if (strstr(ctype, "UTF-8") != NULL) {
@@ -280,5 +272,8 @@ SEXP profiler_start_listen() {
profiler_symb_bfree = "\u2591";
profiler_symb_bfull = "\u2588";
}
- return port;
+
+ // start backgroud listening thread
+ pthread_create(&profiler_pthread, NULL, profiler_thread, NULL);
+ return ntohs(serv_addr.sin_port);
}
diff --git a/sql/scripts/16_tracelog.sql b/sql/scripts/16_tracelog.sql
--- a/sql/scripts/16_tracelog.sql
+++ b/sql/scripts/16_tracelog.sql
@@ -35,3 +35,6 @@ create function sys.tracelog()
external name sql.dump_trace;
create view sys.tracelog as select * from sys.tracelog();
+
+create procedure profiler_openstream(host string, port int) external name
profiler."openStream";
+create procedure profiler_stethoscope(ticks int) external name
profiler.stethoscope;
\ No newline at end of file
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list