diff options
Diffstat (limited to 'lib/dataset_cache.rb')
-rw-r--r-- | lib/dataset_cache.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/dataset_cache.rb b/lib/dataset_cache.rb new file mode 100644 index 0000000..1af1d51 --- /dev/null +++ b/lib/dataset_cache.rb @@ -0,0 +1,23 @@ + +module Lib + + module DatasetCache + + @@cache={} + + # same as OpenTox::Dataset.find with caching function + # rational: datasets are reused in crossvalidation very often, cache to save computational effort + # PENDING: may cause memory issues, test with huge datasets + def self.find(dataset_uri, subjectid=nil) + return nil if (dataset_uri==nil) + d = @@cache[dataset_uri.to_s+"_"+subjectid.to_s] + if d==nil + d = OpenTox::Dataset.find(dataset_uri, subjectid) + @@cache[dataset_uri.to_s+"_"+subjectid.to_s] = d + end + d + end + + end + +end
\ No newline at end of file |