rinruby
rinruby copied to clipboard
R Script limit of 10000 characters
r.eval r_script
appears to error suspiciously at the 10k character mark. Can this be increased?
Hi, I'm a contributor of RinRuby. I think this is probably related to R readBin function of R getting string from Ruby via socket, because its document says "Input strings are limited to 10000 characters". I think this limitation will be overcome by using another R function such as readChar. Could you provide me a quick example?
Sure thing
require 'rinruby'
r = RinRuby.new
r9999 = ("a <- 2 +2/n") * 909
r10000 = ("a <- 2 +2/n") * 908 + "a <- 2 + 2/n"
r9999.size # 9999 character R script
r10000.size # 10000 character R script
r.eval r9999 # Works
r.eval r10000
# irb(main):030:0> r.eval r10000
# Traceback (most recent call last):
# 1: from (irb):30
# RinRuby::ParseError (Parse error on eval:a <- 2 +2/na <- 2 +2/na <- 2 +2/na <- 2 +2/na ...
Thank you. BTW, I think "a <- 2 +2/n" is little odd, did you mean "a <- 2 +2\n"? (Is the last character 'return' ?)
Yes sorry that's what I meant
OK, I will check with the following
require 'rinruby'
r = RinRuby.new
r10000 = ("a <- 2 +2\n") * 1000
r9999 = r10000[0..-2]
r9999.size # 9999 character R script
r10000.size # 10000 character R script
r.eval r9999
r.eval r10000
Or this will do similarly
r9999 = ("a <- 2 +2\n") * 999 + ("a <- 2+2\n") # 9999 characters
r10000 = ("a <- 2 +2\n") * 1000 # 10000 chracters
OK, I've reproduced the error. In addition, I found that my forked version, which additionally supported m17n, seemed to deal with it well. Please try it.
Oh, awesome.
Out of curiosity, why not make a PR upstream if you've improved the functionality etc?
I discussed the maintainer @clbustos , and agreed that the additional (experimental) functionality will not yet be merged into the master. Please see https://github.com/clbustos/rinruby/pull/37#issuecomment-415611739, and forgive me. In this case, I will make a PR to just work around this error.
I wonder if the 10k character limit could be altered (in original rinruby), perhaps without the experimental functionality (for now)? It would be really handy. I'm working with 40 - 80k character scripts and manually moving them into chunks is cumbersome (without taking into account when I make tweaks that I forget to manually copy/paste before every build..)
Although a minor change, it would be very useful
@fenrir-naru switching to your source fixes the 10k limit issue immediately. Great work. This would definitely be very useful in the original rinruby cc @clbustos 😄 👍
@stevecondylios I'm happy to hear of the resolution. I hope this issue will be left open until a fix for the master is commited.
Ok, I will check @fenrir-naru branch to update head branch.
@fenrir-naru, which branch should I review? dev or multibyte?