bd2kccd / r-causal

R Wrapper for Tetrad Library
35 stars 19 forks source link

#106 Fixed. Loading time becomes over 600x faster when alarm dataset is used. #109

Closed yasu-sh closed 2 years ago

yasu-sh commented 2 years ago

Hi developers, loading process: ca. 60 secs to 0.3 secs.

I am confident to improve them, avoiding possible side effects. But I appreciate if developer/contributors could review the codes.

Major issue was sapply function for modify data at every sample. Other time-cosuming process can be improved by the replacement of $.

As long as you know well about Java TETRAD code, it is easy to replace them. I am limited knowledge on Java code. so I feel like somebody to extend this idea...

in rJava help,

rJava provides two levels of API: low-level JNI-API in the form of .jcall function and high-level reflection API based on the $ operator. The former is very fast, but inflexible. The latter is a convenient way to use Java-like programming at the cost of performance. The reflection API is build around the $ operator on jobjRef-class objects that allows to access Java attributes and call object methods.

(cut)

names and .DollarNames returns all fields and methods associated with the object. Method names are followed by ( or () depending on arity. This use of names is mainly useful for code completion, it is not intended to be used programmatically.

This is just a convenience API. Internally all calls are mapped into .jcall calls, therefore the calling conventions and returning objects use the same rules. For time-critical Java calls .jcall should be used directly.

image