IDEA: fst Package for ProjectTemplate Cache will boost Startup performance

12 views
Skip to first unread message

Floris Padt

unread,
Apr 17, 2017, 2:33:30 AM4/17/17
to ProjectTemplate
Dear All,

How knows how I can get the fst package and it functionality build in the ProjectTemplate functionality

Would like to use this feature for loading the Cache of ProjectTemplate.

So in case the same file is in the cache with fst extension and the file is just as old or newer this should be loaded.
In case it is older the system should load the normal file and directly save it as .fst

This does the trick

load_dt <-
  function(pDATA_TABLE, pPATH = PATH_DATA) {

    file_time_format <- "%Y-%m-%d %H:%M:%S"
 
    # if fst version exists load it when it is more recent else load normal .RData file
    if (file.exists(file_fst) &
        strptime(file.mtime(file_fst)  , format = file_time_format) >=
        strptime(file.mtime(file_RData), format = file_time_format)) {
      assign(pDATA_TABLE,
             read.fst(path = file_fst, as.data.table = TRUE),
             envir = .GlobalEnv)
    } else {
      load(file_RData,  envir = .GlobalEnv)
      write.fst(get(pDATA_TABLE), file_fst)
    }
     
    # return()
  }
Reply all
Reply to author
Forward
0 new messages