Skip to content

Commit cd36c3e

Browse files
Sergey Vidyuksv
Sergey Vidyuk
authored andcommitted
update error messaging and docs
1 parent a8a3f6a commit cd36c3e

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

R/rkdb.R

+3-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @param port Port number.
55
#' @param user Username and password as user:password string
66
#' @param timeout Number of milliseconds to wait for connection
7-
#' @param tls Wether or not to use secure connection. Alway false(unsupported).
7+
#' @param tls Whether or not to use secure connection. Alway false(unsupported).
88
#' @return Handle to kdb+ instance for \code{execute} and \code{close_connection}.
99
#' @export
1010
#' @examples
@@ -20,9 +20,9 @@ open_connection <- function(host="localhost", port=5000, user="", timeout = 0,
2020

2121
#' Execute \code{query} using \code{connection} connection to kdb+.
2222
#'
23-
#' @param connection Connection handle. handle>0 will perform sync requst, handle<0 async.
23+
#' @param connection Connection handle. handle>0 will perform sync request, handle<0 async.
2424
#' @param query A string to send to kdb+.
25-
#' @param ... Optional parameters to pass to function provided in query.
25+
#' @param ... Optional parameters to pass to function provided in the query.
2626
#' @return Result of execution.
2727
#' @export
2828
#' @examples
@@ -49,11 +49,3 @@ execute <- function(connection, query, ...) {
4949
close_connection <- function(con) {
5050
.Call("kx_r_close_connection", as.integer(con))
5151
}
52-
53-
# library(rkdb)
54-
# hdl=open_connection(port=4537)
55-
# tmp <- data.frame(a=c(1,2,3),b=c("a","b","b"))
56-
# class(tmp$b)
57-
# dict()
58-
# class(tmp)
59-
# execute(hdl,'{`tmp set x}',data.frame(a=c(1,2,3),b=c("a","b","b")))

doc/README.Rmd

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if(! 'devtools' %in% rownames(installed.packages())) install.packages('devtools'
4444
library(devtools)
4545
# install rkdb
4646
devtools::install_github('kxsystems/rkdb', quiet=TRUE)
47-
# to install rkdb of perticular release
47+
# to install rkdb of particular release
4848
# devtools::install_github('kxsystems/[email protected]', quiet=TRUE)
4949
library(rkdb)
5050
```
@@ -58,7 +58,7 @@ q -p params$port
5858

5959
Open a connection to it
6060
```{r open connection, echo=TRUE}
61-
h <- open_connection(params$server,params$port) #this open a connection
61+
h <- open_connection(params$server,params$port) #this opens a connection
6262
```
6363

6464
## Hello kdb
@@ -114,7 +114,7 @@ cat("
114114

115115
## Computing on kdb
116116

117-
rkdb provides a convienient way to retrieve computation done on the kdb side so you can have the best of both worlds:
117+
rkdb provides a convenient way to retrieve computation done on the kdb side so you can have the best of both worlds:
118118
```{r kdb side example 1, echo=TRUE, warning=FALSE, message=FALSE}
119119
kdb <- '
120120
t: ([] x:1000#`a`b`c;y:1000#1f*til 10;z:1000#1f*til 4);
@@ -138,7 +138,7 @@ plot(DF$y, DF$z, main='scatter plot', xlab='y values', ylab='z values')
138138
# Getting data from R to kdb
139139
## Evaluating kdb expressions using R objects
140140

141-
You can call kdb functions on R objects, those will be passed/converted to the kdb side, and the kdb expression will be evaluated:
141+
You can call kdb functions with R objects as arguments, those will be passed and converted to native kdb+ data types, and the kdb expression will be evaluated:
142142
```{r use r obj 1, echo=TRUE}
143143
execute(h, "raze", list(c(1,2,3), c(4,5,6)))
144144
execute(h, "+", 2, 5)

man/execute.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/open_connection.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SEXP kx_r_open_connection(SEXP whence) {
2828
char *host,*user;
2929
int length= GET_LENGTH(whence);
3030
if(length != 5)
31-
error("Expecting 5 parameters: host, port, user, timeout, tls. Got ",length);
31+
error("Expecting 5 parameters: host, port, user, timeout, tls. Got %d.",length);
3232

3333
host= (char *) CHARACTER_VALUE(VECTOR_ELT(whence, 0));
3434
port= INTEGER_POINTER(VECTOR_ELT(whence, 1))[0];
@@ -37,9 +37,9 @@ SEXP kx_r_open_connection(SEXP whence) {
3737

3838
connection= khpun(host, port, user,timeout);
3939
if(!connection)
40-
error("Could not authenticate");
40+
error("Could not authenticate.");
4141
else if(connection ==-2 )
42-
error("Connection timed out");
42+
error("Connection timed out.");
4343
else if(connection ==-1 ) {
4444
#ifdef WIN32
4545
char buf[256];
@@ -82,10 +82,10 @@ SEXP kx_r_execute(SEXP connection, SEXP query, SEXP args) {
8282
size_t nargs= LENGTH(args);
8383

8484
if(nargs > 8) {
85-
error("Error: kdb+ functions take a maximum of 8 parameters");
85+
error("kdb+ functions take a maximum of 8 parameters.");
8686
}
8787
if(TYPEOF(query) != STRSXP) {
88-
error("Error: supplied query or function name must be a string");
88+
error("Supplied query or function name must be a string.");
8989
}
9090
query_str= (char *) CHARACTER_VALUE(query);
9191
K kargs[8]= { (K) 0 };
@@ -97,14 +97,14 @@ SEXP kx_r_execute(SEXP connection, SEXP query, SEXP args) {
9797
kargs[4], kargs[5], kargs[6], kargs[7], (K) 0);
9898

9999
if(0 == result) {
100-
error("Error: not connected to kdb+ server\n");
100+
error("Not connected to kdb+ server.");
101101
} else if(kx_connection < 0) { // async IPC
102102
return R_NilValue;
103103
} else if(-128 == result->t) {
104104
char *e= calloc(strlen(result->s) + 1, 1);
105105
strcpy(e, result->s);
106106
r0(result);
107-
error("Error from kdb+: `%s\n", e);
107+
error("kdb+ : %s.", e);
108108
}
109109
s= from_any_kobject(result);
110110
r0(result);

0 commit comments

Comments
 (0)