3 ##############################
4 # Follow steps in README first
5 ##############################
7 nb_curves_per_request <- 100 #curves per (select) request
9 # Init connection with DB
10 driver <- PostgreSQL(fetch.default.rec = nb_curves_per_request)
11 con <- dbConnect(driver, user="irsdi", password="irsdi2017",
12 host="localhost", port="5432", dbname="edf25m")
14 # Fill associative array, map index to identifier
15 indexToID_inDB <- as.character(
16 dbGetQuery(con, 'SELECT DISTINCT id FROM series')[,"id"] )
18 # Function to retrieve curves within some indices range
19 getCurves <- function(indices)
21 indices = indices[ indices <= length(indexToID_inDB) ]
22 if (length(indices) == 0)
24 request <- "SELECT curve FROM series WHERE id in ("
25 for (i in seq_along(indices))
27 request <- paste(request, indexToID_inDB[ indices[i] ], sep="")
28 if (i < length(indices))
29 request <- paste(request, ",", sep="")
31 request <- paste(request, ")", sep="")
32 df_series <- dbGetQuery(con, request)
34 #weird result: an integer, and then string "{val1,val2,val3,...,valD}" :/
35 #print(summary(df_series))
37 # matrix(df_series[,"value"], ncol=length(indices))
41 #curves <- getCurves(c(1:3,7,11))
43 res <- claws(getCurves, 50, 15, 500, 500, random=FALSE, ncores_clust=3, verbose=TRUE)