private RConnection setupConnection() throws REXPMismatchException, RserveException { // Set up an Rserve connection logger.fine("RSERVE_USER="+RSERVE_USER+"[default=rserve]"); logger.fine("RSERVE_PASSWORD="+RSERVE_PWD+"[default=rserve]"); logger.fine("RSERVE_PORT="+RSERVE_PORT+"[default=6311]"); logger.fine("RSERVE_HOST="+RSERVE_HOST); RConnection connection = new RConnection(RSERVE_HOST, RSERVE_PORT); connection.login(RSERVE_USER, RSERVE_PWD); logger.fine(">" + connection.eval("R.version$version.string").asString() + "<"); // check working directories // This needs to be done *before* we try to create any files // there! setupWorkingDirectory(connection); return connection; }
variableTypeName = !columnMeta.at("type.string").isNull() ? columnMeta.at("type.string").asString() : null; variableLevels = !columnMeta.at("levels").isNull() ? columnMeta.at("levels").asStrings() : new String[0]; variableFormat = !columnMeta.at("format").isNull() ? columnMeta.at("format").asString() : null;
private Map<String, String> buildResult(RConnection connection, String dsnprfx, int wbFileSize, Map<String, String> result) throws RserveException, REXPMismatchException { // If the above succeeded, the dataframe has been saved on the // Rserve side as an .Rdata file. Now we can transfer it back to the // dataverse side: File localDataFrameFile = transferRemoteFile(connection, dsnprfx, RWRKSP_FILE_PREFIX,"RData", wbFileSize); if (localDataFrameFile != null){ logger.fine("data frame file name: "+localDataFrameFile.getAbsolutePath()); result.put("dataFrameFileName",localDataFrameFile.getAbsolutePath()); } else { logger.warning("data frame file is null!"); // throw an exception?? } result.put("Rversion", connection.eval("R.Version()$version.string").asString()); logger.fine("result object (before closing the Rserve):\n"+result); String deleteLine = "file.remove('"+tempFileNameIn+"')"; connection.eval(deleteLine); connection.close(); return result; }
case XT_STR: case XT_SYMNAME: l+=(cont==null)?1:(cont.asString().length()+1); if ((l&3)>0) l=l-(l&3)+4; break;
mParent = directoryNames.at("parent").asString(); } else { LOG.fine("WARNING: directoryNames at \"parent\" is null!");
case XT_STR: case XT_SYMNAME: l+=(cont==null)?1:(cont.asString().length()+1); if ((l&3)>0) l=l-(l&3)+4; break;
result.put("Rversion", connection.eval("R.Version()$version.string").asString());
script = inputName + " <- " + value.asString() + ";\n" + script; } else { String[] strings = value.asStrings(); REXP r = connection.parseAndEval("try(eval(parse(text=.tmp.)),silent=TRUE)"); if (r.inherits("try-error")) { String errorString = r.asString(); if (errorString.contains(": ")) { errorString = errorString.substring(errorString.indexOf(": ") + 2); REXP results = connection.parseAndEval("try(eval(parse(text=.tmp.)),silent=TRUE)"); if (results.inherits("try-error")) { String errorString = results.asString(); if (errorString.contains(": ")) { errorString = errorString.substring(errorString.indexOf(": ") + 2);
throw new RException(r.asString());
REXP ca = getAttr().asList().at("class"); REXP ls = getAttr().asList().at("levels"); if (ca != null && ls != null && ca.asString().equals("factor")) { if (xt==XT_LIST_TAG || xt==XT_LANG_TAG) { o = nf.parseREXP(buf, o); if (nf.cont.isSymbol() || nf.cont.isString()) name = nf.cont.asString(); rootList.setKeyAt(elIndex, tagf.cont.asString()); Object oa[] = l.toArray(); names = new String[oa.length]; for(int i = 0; i < oa.length; i++) names[i] = ((REXP)oa[i]).asString(); REXPFactory xx=new REXPFactory(); o = xx.parseREXP(buf,o); v.addElement(xx.cont.asString()); REXPFactory sym = new REXPFactory(); cont = new REXPSymbol(sym.getREXP().asString()); // content of a symbol is its printname string (so far) o=eox; return o;
throw new RException(result.asString());
REXP ca = getAttr().asList().at("class"); REXP ls = getAttr().asList().at("levels"); if (ca != null && ls != null && ca.asString().equals("factor")) { if (xt==XT_LIST_TAG || xt==XT_LANG_TAG) { o = nf.parseREXP(buf, o); if (nf.cont.isSymbol() || nf.cont.isString()) name = nf.cont.asString(); rootList.setKeyAt(elIndex, tagf.cont.asString()); Object oa[] = l.toArray(); names = new String[oa.length]; for(int i = 0; i < oa.length; i++) names[i] = ((REXP)oa[i]).asString(); REXPFactory xx=new REXPFactory(); o = xx.parseREXP(buf,o); v.addElement(xx.cont.asString()); REXPFactory sym = new REXPFactory(); cont = new REXPSymbol(sym.getREXP().asString()); // content of a symbol is its printname string (so far) o=eox; return o;
getStringBinaryRepresentation(buf, off, cont.asString()); break;
getStringBinaryRepresentation(buf, off, cont.asString()); break;
strOutput.emit(retVal.asString());
strOutput.emit(retVal.asString());