问题描述
在 Java 中将大字符串值分配给 Rserve 时出现异常
public void run(String data) {//800
RConnection c =null;
long startTime = System.nanoTime();
ObjectMapper mapper = new ObjectMapper();
try {
c = new RConnection();
if (c.isConnected()) {
System.out.println("*** R serve is connected..");
} else {
System.err.println("R serve is not available");
}
System.out.println("data set length-->"+data.length());
c.assign("poleData",data);//This line is throwing error
c.eval(String.format("source(" + rScript + ")"));
REXP result =c.eval("imputResult");
System.out.println("Completed.."+imputeData.toPrettyString());
long endTime = System.nanoTime();
//System.out.println("Time end -->"+endTime);
long duration = endTime - startTime;
// System.out.println("Total time diff in nanosecond-->"+(endTime-startTime));
double diff = (double) duration / 1000000000;
// System.out.println("Total time diff -->" + diff + " second");
// c.close();
} catch (RserveException e) {
e.printstacktrace();
} catch (Exception e) {
e.printstacktrace();
} finally {
if(c!=null) {
c.close();
System.out.println("Connection closed..");
}
}
}
}
例外
*** R 服务已连接.. 数据集长度-->58784021 java.lang.Arrayindexoutofboundsexception:索引 8452396 超出长度 8452396 的范围 在 org.rosuda.REngine.Rserve.RConnection.assign(RConnection.java:254) 在 com.app.Imputaionjson$Task.run(Imputaionjson.java:190) 在 java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) 在 java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) 在 java.base/java.lang.Thread.run(Thread.java:834) 连接已关闭..
请帮忙解决这个问题..
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)