fastr | Event-based web framework for Ruby
kandi X-RAY | fastr Summary
kandi X-RAY | fastr Summary
Event-based web framework for Ruby.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Dispatch controller to controller
- Tries to match a Rack environment .
- Initializes the application .
- Sets a cookie .
- retrieves a route
- Render a template
- Dispatches the request to the server .
- Respond to controller routes
- Add a route to the path
- Watch that the file has been loaded .
fastr Key Features
fastr Examples and Code Snippets
Community Discussions
Trending Discussions on fastr
QUESTION
If I call R code from Java within GraalVM (using GraalVM's polyglot function), does the R code and the Java code run on the same Java thread (ie there's no switching between OS or Java threads etc?) Also, is it the same "memory/heap" space? That is, in the example code below (which I took from https://www.baeldung.com/java-r-integration)
...ANSWER
Answered 2022-Feb-02 at 20:50does the R code and the Java code run on the same Java thread. Also, is it the same "memory/heap" space?
Yes and yes. You can even use GraalVM VisualVM to inspect the heap: it provides standard Java view where you can see instances of FastR internal representations like RIntVector
mingled with the rest of the other Java objects, or R view where you can see integer vectors, lists, environments, ...
does the call rBindings.getMember("c").execute(values) cause the values object (an array of ints) to be copied?
In general yes: most objects are passed to R as-is. Inside R you have two choices:
- Explicitly convert them to some concrete type, i.e.,
as.integer(arg)
, which does not make a copy, but tells R explicitly how you want that value to be treated as "native" R type including R's value semantics. - Leave it up to the default rules, which will be applied once your objects is passed to some R builtin, e.g.,
int[]
is treated as integer vector (but note that treating it as a list would be also reasonable in some cases). Again no copies here. And the object itself keeps its reference semantics.
However, sometimes FastR needs to make a copy:
- some builtin functions cannot handle foreign objects yet
- R language often implicitly copies vectors, because of its value semantics, arguments coercion, etc.
- when a vector is passed to native R extension, we need to move its data to off heap memory
I would say that if you happen to have a very large vector, say GBs of data, you need to be very careful about it even in regular R. Note: FastR vectors are by default backed by Java arrays, so their size limitations apply to FastR vectors too.
Finally, does calling a polyglot function (in this case customMean implemented in R) have the same overhead as calling a native Java function?
Mostly yes, except that the function cannot be pulled and inlined into the surrounding Java code(+). The call itself is as fast as regular Java call. For the example you give: it cannot be optimized as you suggest, because the R function cannot be inlined(+). However, I would be very skeptical that any compiler can optimize this as you suggest even if both functions where pure Java code. That being said, yes: some things that compiler can optimize, like eliminating some useless computations that it can analyze well, is not going to work because of the impossibility to inline code across the Java <-> R boundary(+).
(+) Unless you'd run the Java code with Espresso (Java on Truffle), but then you would not be using Context API but Espresso's interop support.
QUESTION
I plan to write an R script using FastR implementation which looks like
...ANSWER
Answered 2021-Dec-31 at 09:35Run the R script with the provided jar
It seems that you figured it out yourself. Either you can use java.addToClasspath
or you should be able to add to the class path when starting R/Rscript by --vm.cp=...
. Both options work only in the JVM mode.
Execute the script with Rscript
Again, seems you figured it out?
Pass a function to the executor from the R script so that the function is called accordingly by the ScheduledExecutorService
This is tricky. R is single threaded language and so is FastR. You cannot execute R code from multiple threads, but what you can do is to create multiple FastR contexts and use a new context in each thread (you can use ThreadLocal for that). See https://www.graalvm.org/reference-manual/embed-languages. You should be able to use the Context API from the Java code that you call from R and create new contexts.
Build a native image with the runnable script and jar
That should be fine. Note that there are some known issues with some R packages and native image that we have not fixed yet.
The entry point must be some Java application that uses the Context API to start FastR. The R script you can embed into the Java application as a String or a resource. Note that the R code will not be ahead-of-time compiled. It will still be JIT compiled at runtime, but everything else will be ahead-of-time compiled: your Java code, any Java libs you use, FastR interpreter and runtime.
QUESTION
I am using Cordova CLI 9.0, Cordova-Android 9.0, and an Ionic 4 Web application. It runs okay, but I keep getting these errors for my plugins:
...ANSWER
Answered 2021-Mar-23 at 18:32I was able to find 2 different places that are calling functions on cordova_plugins. I commented out these functions from the phonegap/plugins Injecter and it seemed to get rid of all the errors.
QUESTION
I want release library for 2.12 and 2.13 scala version. But it depends on another library, which exist for 2.12 only. For 2.13 I wrote my implementation for fast
function:
2.12 code looks:
...ANSWER
Answered 2020-Mar-18 at 16:18Having different imports is problematic, because that means you have different sources (and you need to maintain them). I think providing missing implementation of library in it's own original package will be better solution.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fastr
On a UNIX-like operating system, using your system’s package manager is easiest. However, the packaged Ruby version may not be the newest one. There is also an installer for Windows. Managers help you to switch between multiple Ruby versions on your system. Installers can be used to install a specific or multiple Ruby versions. Please refer ruby-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page