JuliaInterface-class: An Interface to Julia

Description Fields Methods

Description

The JuliaInterface class provides an evaluator for computations in Julia, following the structure in the XR package. Proxy functions and classes allow use of the interface with no explicit reference to the evaluator. The function RJulia() returns an evaluator object.

Fields

host

The remote host, as a character string. By default this will be the local host, and initializing the evalutor will set the field to "localhost".

port

The port number for commuicating to Julia from this evalutor. By default, the port is set by adding the evaluator number-1 to a base port number. By default the base port is randomly chosen at package load time (this strategy may change).

The port may be controlled in two ways. If you know a good range or set of ports, it will be preferrable to supply unique port values (integer) in the initialization call. A less direct way is set the R option "JuliaBasePort", which will then be used as the base port. Since evaluator numbers are used to increment the port, the call to options should normally come before initializing the first Julia evaluator.

julia_bin

The location for an executable version of the Julia interpreter. By default, this assumes there is a file named "julia" on the command-line search path. If Julia is not usable from the command line or if you want to run with a different version, supply the executable file name as this argument. It is also possible to set the location for all evaluators by setting the shell variable JULIA_BIN to this location before starting R.

connection

The connection object through which commands are sent to Julia. Normally will be created by the initialization of the evaluator. Should only be supplied as a currently open socket on which to communicate with the Julia interpreter.

serverWrapup

a vector of actions for the ServerEval to take after evaluation. Used to clean up after special operations, such as sending large objects to Julia.

largeObject

Vectors with length bigger than this will be handled specially. See largeVectors. Default currently 1000. To change this, call juliaOptions() to set option largeObject.

fileBase

a pattern for file names that the evaluator will use in Julia for various data transfer and other purposes. The evaluator appends "_1", "_2", etc. To change this, call juliaOptions() to set option fileBase. It is initiaized to an R tempfile with pattern "Julia".

Methods

Import(module, ...)

Import the module. The "Interface" method assumes a command "import" in the server language and does not handle any extra arguments (e.g., for importing specific members).

initialize(...)

initializes the evaluator in a language-independent sense.

ProxyClassName(serverClass)

If there is a proxy class defined corresponding to this serverClass, return the name of that class (typically pasted with the server langauge, separated by underscore). If no such class is defined, return NA.

ServerClassDef(Class, module, ...)

Individual interface packages will define this to return a named list or other object such that value$fields and value$methods are the server fields and methods, character vectors of names or named objects whose elements give further information. This default version returns NULL, indicating that no metadata is available.

ServerEval(expr, key, get)

Must be defined by the server language interface: evaluates 'expr'(a text string). If 'key' is an empty string, 'expr' is treated as a directive, with no defined value. Otherwise, 'key' is a non-empty string, and the server object should be assigned with this name. The value returned is the R result, which may be an AssignedProxy() object. If 'get' is TRUE or the value judged simple enough, it will be converted to an ordinary R object instead.

ServerRemove(key)

Should be defined by the server language interface: The reference previously created for 'key' should be removed. What happens has no effect on the client side; the intent is to potentially recover memory.

ServerTask(task, expr, key = "", get = NA)

Call the task operation in the Julia code for the interface; the arguments must be the simple strings or logical value expected.

Source(filename)

Parse and evaluate the contents of the file. This method is likely to be overriden for particular langauges with a directive to include the contents of the file. The 'XR' version reads the file and processes the entire contents as a single string, newlines inserted between lines of the file.

Using(...)

The Julia "using" form of importing. Arguments are module names. All the exported members of these modules will then be available, without prefix.


johnmchambers/XRJulia documentation built on Aug. 2, 2018, 7:15 p.m.