Reputation: 15
Getting exception when I assign large String value to Rserve in Java
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..");
}
}
}
}
Exception
*** R serve is connected.. data set length-->58784021 java.lang.ArrayIndexOutOfBoundsException: Index 8452396 out of bounds for length 8452396 at org.rosuda.REngine.Rserve.RConnection.assign(RConnection.java:254) at com.app.ImputaionJson$Task.run(ImputaionJson.java:190) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Connection closed..
Please help on this..
Upvotes: 0
Views: 64