Skip to content

Commit f47f184

Browse files
committed
Rapi 3.0.0.0 Release
1 parent d11ac88 commit f47f184

17 files changed

+564
-183
lines changed

R/RDolphinDB_impl.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,7 @@ DDB_UploadVectorDateTime <- function(vec) {
557557
# call different C++ functions to upload vectors.
558558
# At the same time, deal with NA in vectors.
559559
DDB_UploadVector <- function(vec) {
560-
if (all(is.na(vec))) {
561-
562-
UploadVectorNULL(length(vec), 1L)
563-
564-
} else if (is.logical(vec)) {
560+
if (is.logical(vec)) {
565561

566562
NAIndex <- DDB_SetUploadVectorNA(vec)
567563
UploadVectorBool(vec, NAIndex)
@@ -709,6 +705,9 @@ DDB_UploadObjectCheck <- function(args) {
709705
# call the different functions to upload
710706
# different forms of objects.
711707
DDB_UploadEntity <- function(args) {
708+
if(length(args) == 0){
709+
return (TRUE)
710+
}
712711
for (i in 1:length(args)) {
713712
if (is.matrix(args[[i]])) {
714713
DDB_UploadMatrix(args[[i]])

src/include/R_CPP_Connector.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void Rcpp_Connector::Rcpp_UploadDateVector(vector <double>& vec, vector <int>& N
126126
{
127127
for (unsigned int i = 0; i < NAIndex.size(); i++)
128128
{
129-
vec[NAIndex[i]] = DDB_NULL_INTEGER;
129+
vec[NAIndex[i] - 1] = DDB_NULL_INTEGER;
130130
}
131131
/*
132132
vector <int> upload_date;
@@ -161,7 +161,7 @@ void Rcpp_Connector::Rcpp_UploadDateTimeVector(vector <double>& vec, vector <int
161161
{
162162
for (unsigned int i = 0; i < NAIndex.size(); i++)
163163
{
164-
vec[NAIndex[i]] = DDB_NULL_INTEGER;
164+
vec[NAIndex[i] - 1] = DDB_NULL_INTEGER;
165165
}
166166
/*
167167
vector <int> upload_date_time;
@@ -251,7 +251,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <double>& mtx, vector <int>& NAInd
251251
{
252252
for (unsigned int i = 0; i < NAIndex.size(); i++)
253253
{
254-
mtx[NAIndex[i]] = DDB_NULL_NUMERIC;
254+
mtx[NAIndex[i] - 1] = DDB_NULL_NUMERIC;
255255
}
256256

257257
Buffer buffer;
@@ -270,7 +270,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <int>& mtx, vector <int>& NAIndex,
270270
{
271271
for (unsigned int i = 0; i < NAIndex.size(); i++)
272272
{
273-
mtx[NAIndex[i]] = DDB_NULL_INTEGER;
273+
mtx[NAIndex[i] - 1] = DDB_NULL_INTEGER;
274274
}
275275

276276
Buffer buffer;
@@ -295,7 +295,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <bool>& mtx, vector <int>& NAIndex
295295
}
296296
for (unsigned int i = 0; i < NAIndex.size(); i++)
297297
{
298-
convert[NAIndex[i]] = DDB_NULL_BYTE;
298+
convert[NAIndex[i] - 1] = DDB_NULL_BYTE;
299299
}
300300

301301
Buffer buffer;
@@ -344,7 +344,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <string>& vec, vector <int>& NAInd
344344
{
345345
for (unsigned int i = 0; i < NAIndex.size(); i++)
346346
{
347-
vec[NAIndex[i]] = "";
347+
vec[NAIndex[i] - 1] = "";
348348
}
349349

350350
Buffer buffer;
@@ -365,7 +365,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <double>& vec, vector <int>& NAInd
365365
{
366366
for (unsigned int i = 0; i < NAIndex.size(); i++)
367367
{
368-
vec[NAIndex[i]] = DDB_NULL_NUMERIC;
368+
vec[NAIndex[i] - 1] = DDB_NULL_NUMERIC;
369369
}
370370

371371
Buffer buffer;
@@ -392,7 +392,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <bool>& vec, vector <int>& NAIndex
392392
}
393393
for (unsigned int i = 0; i < NAIndex.size(); i++)
394394
{
395-
convert[NAIndex[i]] = DDB_NULL_BYTE;
395+
convert[NAIndex[i] - 1] = DDB_NULL_BYTE;
396396
}
397397

398398
Buffer buffer;
@@ -413,7 +413,7 @@ void Rcpp_Connector::Rcpp_UploadEntity(vector <int>& vec, vector <int>& NAIndex)
413413
{
414414
for (unsigned int i = 0; i < NAIndex.size(); i++)
415415
{
416-
vec[NAIndex[i]] = DDB_NULL_INTEGER;
416+
vec[NAIndex[i] - 1] = DDB_NULL_INTEGER;
417417
}
418418

419419
Buffer buffer;

src/include/Utill.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ string Utill::ParseDateTime(int seconds)
455455

456456
int Utill::CountDays(string date_str)
457457
{
458+
if(date_str == "NA"){
459+
return DDB_NULL_INTEGER;
460+
}
458461
string year_str(date_str, 0, 4);
459462
string month_str(date_str, 5, 2);
460463
string day_str(date_str, 8, 2);
@@ -504,6 +507,9 @@ int Utill::CountDays(string date_str)
504507

505508
int Utill::CountSeconds(string date_time_str)
506509
{
510+
if(date_time_str == "NA"){
511+
return DDB_NULL_INTEGER;
512+
}
507513
string date_str(date_time_str, 0, 10);
508514
int hour;
509515
int minute;

src/include/Vectorr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ class VectorShort : public Vectorr
271271
class VectorDate : public Vectorr
272272
{
273273
private:
274-
Rcpp::NumericVector _vec;
274+
Rcpp::DateVector _vec;
275275

276276
vector<string> str_vec;
277277
vector<int> origin_v;
278278
public:
279279
VectorDate(DataInputStream &in)
280-
:Vectorr(in)
280+
:Vectorr(in), _vec(0)
281281
{
282282
int size = Vectorr::getRow() * Vectorr::getClm();
283283
int y, m, d;

test/TestConnect.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ library(RDolphinDB)
55

66
record <- c(0L,0L)
77
# host error
8-
conn <- dbConnect(DolphinDB(),"192.168.0.1",PORT)
8+
conn <- dbConnect(DolphinDB(),"192.1.1.1",PORT)
99
record <- assert(record,"connect host error",conn@connected,FALSE)
1010

1111
# port error

test/TestRpcBasic.R

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
source("setup/Settings.R")
2+
source("pub/Assert.R")
3+
4+
library(RDolphinDB)
5+
6+
conn <- dbConnect(DolphinDB(),HOST,PORT,USER,PASSWD)
7+
if (conn@connected){
8+
record <- c(0L,0L)
9+
. <- dbRun(conn,"
10+
def test_rpc0(){
11+
return true
12+
}
13+
14+
def test_rpc1(x){
15+
return true
16+
}
17+
18+
def test_rpc2(x,y){
19+
return true
20+
}
21+
")
22+
23+
# 0 params
24+
result <- dbRpc(conn,"test_rpc0",list())
25+
record <- assert(record,"test dbRpc 0 params",result,TRUE)
26+
27+
# 1 params
28+
result <- dbRpc(conn,"test_rpc1",list(1))
29+
record <- assert(record,"test dbRpc 1 params",result,TRUE)
30+
31+
# 2 params
32+
result <- dbRpc(conn,"test_rpc2",list(1,2))
33+
record <- assert(record,"test dbRpc 2 params",result,TRUE)
34+
35+
# part apply
36+
result <- dbRpc(conn,"test_rpc2{0}",list(1))
37+
record <- assert(record,"test dbRpc part apply",result,TRUE)
38+
39+
result <-
40+
41+
printTestResult(record)
42+
conn <- dbClose(conn)
43+
} else {
44+
stop("connect error in TestRpcBasic.R")
45+
}

test/TestRunMatrix.R

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,33 @@ if (conn@connected){
1515

1616
# char
1717
result <- dbRun(conn,"x=matrix([0c,127c,00c],[0c,127c,00c]);x.rename!(`row1`row2`row3,`col1`col2);x")
18-
expect <- matrix(c(0L,127L,NA,0L,127L,NA),nrow=3,byrow=FALSE)
18+
expect <- matrix(c(0L,127L,NA_integer_,0L,127L,NA_integer_),nrow=3,byrow=FALSE)
1919
colnames(expect) <- c("col1","col2")
2020
rownames(expect) <- c("row1","row2","row3")
2121
record <- assert(record,"download matrix char 1",result,expect)
2222

2323
# short
2424
result <- dbRun(conn,"x=matrix([0h,32767h,00h],[0h,32767h,00h]);x.rename!(`row1`row2`row3,`col1`col2);x")
25-
expect <- matrix(c(0L,32767L,NA,0L,32767L,NA),nrow=3,byrow=FALSE)
25+
expect <- matrix(c(0L,32767L,NA_integer_,0L,32767L,NA_integer_),nrow=3,byrow=FALSE)
2626
colnames(expect) <- c("col1","col2")
2727
rownames(expect) <- c("row1","row2","row3")
2828
record <- assert(record,"download matrix short 1",result,expect)
2929

3030
# int
3131
result <- dbRun(conn,"x=matrix([0i,2147483647i,00i],[0i,2147483647i,00i]);x.rename!(`row1`row2`row3,`col1`col2);x")
32-
expect <- matrix(c(0L,2147483647L,NA,0L,2147483647L,NA),nrow=3,byrow=FALSE)
32+
expect <- matrix(c(0L,2147483647L,NA_integer_,0L,2147483647L,NA_integer_),nrow=3,byrow=FALSE)
3333
colnames(expect) <- c("col1","col2")
3434
rownames(expect) <- c("row1","row2","row3")
3535
record <- assert(record,"download matrix int 1",result,expect)
3636

3737
# long
3838
result <- dbRun(conn,"x=matrix([0l,9223372036854775807l,00l],[0l,9223372036854775807l,00l]);x.rename!(`row1`row2`row3,`col1`col2);x")
39-
expect <- matrix(c(0L,9223372036854775807,NA,0L,9223372036854775807,NA),nrow=3,byrow=FALSE)
39+
expect <- matrix(c(0L,9223372036854775807,NA_real_,0L,9223372036854775807,NA_real_),nrow=3,byrow=FALSE)
4040
colnames(expect) <- c("col1","col2")
4141
rownames(expect) <- c("row1","row2","row3")
4242
record <- assert(record,"download matrix long 1",result,expect)
4343

4444
# date
45-
# todo:转为character?
4645
result <- dbRun(conn,"x=matrix([1970.01.01d,00d],[1970.01.01d,00d]);x.rename!(`row1`row2,`col1`col2);x")
4746
expect <- matrix(c("1970-01-01",NA,"1970-01-01",NA),nrow=2,byrow=FALSE)
4847
colnames(expect) <- c("col1","col2")
@@ -57,7 +56,6 @@ if (conn@connected){
5756
record <- assert(record,"download matrix month 1",result,expect)
5857

5958
# time
60-
# todo:008被舍去?
6159
result <- dbRun(conn,"x=matrix([13:30:10.008t,00t],[13:30:10.008t,00t]);x.rename!(`row1`row2,`col1`col2);x")
6260
expect <- matrix(c("1970-01-01 13:30:10",NA,"1970-01-01 13:30:10",NA),nrow=2,byrow=FALSE)
6361
colnames(expect) <- c("col1","col2")
@@ -86,23 +84,20 @@ if (conn@connected){
8684
record <- assert(record,"download matrix datetime 1",result,expect)
8785

8886
# timestamp
89-
# todo:008被舍去?
9087
result <- dbRun(conn,"x=matrix([2012.06.13T13:30:10.008T,00T],[2012.06.13T13:30:10.008T,00T]);x.rename!(`row1`row2,`col1`col2);x")
9188
expect <- matrix(c("2012-06-13 13:30:10",NA,"2012-06-13 13:30:10",NA),nrow=2,byrow=FALSE)
9289
colnames(expect) <- c("col1","col2")
9390
rownames(expect) <- c("row1","row2")
9491
record <- assert(record,"download matrix timestamp 1",result,expect)
9592

9693
# nanotime
97-
# todo:008被舍去?
9894
result <- dbRun(conn,"x=matrix([13:30:10.008007006n,00n],[13:30:10.008007006n,00n]);x.rename!(`row1`row2,`col1`col2);x")
9995
expect <- matrix(c("1970-01-01 13:30:10",NA,"1970-01-01 13:30:10",NA),nrow=2,byrow=FALSE)
10096
colnames(expect) <- c("col1","col2")
10197
rownames(expect) <- c("row1","row2")
10298
record <- assert(record,"download matrix nanotime 1",result,expect)
10399

104100
# nanotimestamp
105-
# todo:008被舍去?
106101
result <- dbRun(conn,"x=matrix([2012.06.13T13:30:10.008007006N,00N],[2012.06.13T13:30:10.008007006N,00N]);x.rename!(`row1`row2,`col1`col2);x")
107102
expect <- matrix(c("2012-06-13 13:30:10",NA,"2012-06-13 13:30:10",NA),nrow=2,byrow=FALSE)
108103
colnames(expect) <- c("col1","col2")
@@ -111,25 +106,18 @@ if (conn@connected){
111106

112107
# float
113108
result <- dbRun(conn,"x=matrix([0.0f,float('nan'),float('inf'),00f],[0.0f,float('nan'),float('inf'),00f]);x.rename!(`row1`row2`row3`row4,`col1`col2);x")
114-
expect <- matrix(c(0,NaN,Inf,NA,0,NaN,Inf,NA),nrow=4,byrow=FALSE)
109+
expect <- matrix(c(0,NaN,Inf,NA_real_,0,NaN,Inf,NA_real_),nrow=4,byrow=FALSE)
115110
colnames(expect) <- c("col1","col2")
116111
rownames(expect) <- c("row1","row2","row3","row4")
117112
record <- assert(record,"download matrix float 1",result,expect)
118113

119114
# double
120115
result <- dbRun(conn,"x=matrix([0.0F,00F],[0.0F,00F]);x.rename!(`row1`row2,`col1`col2);x")
121-
expect <- matrix(c(0,NA,0,NA),nrow=2,byrow=FALSE)
116+
expect <- matrix(c(0,NA_real_,0,NA_real_),nrow=2,byrow=FALSE)
122117
colnames(expect) <- c("col1","col2")
123118
rownames(expect) <- c("row1","row2")
124119
record <- assert(record,"download matrix double 1",result,expect)
125120

126-
# empty
127-
result <- dbRun(conn,"x=matrix(INT,3,2);x.rename!(`row1`row2`row3,`col1`col2);x")
128-
expect <- matrix(c(0L,0L,0L,0L,0L,0L),nrow=3,byrow=FALSE)
129-
colnames(expect) <- c("col1","col2")
130-
rownames(expect) <- c("row1","row2","row3")
131-
record <- assert(record,"download matrix empty 1",result,expect)
132-
133121
printTestResult(record)
134122
conn <- dbClose(conn)
135123
} else {

0 commit comments

Comments
 (0)