rinruby icon indicating copy to clipboard operation
rinruby copied to clipboard

R Script limit of 10000 characters

Open stevecondylios opened this issue 6 years ago • 14 comments

r.eval r_script appears to error suspiciously at the 10k character mark. Can this be increased?

stevecondylios avatar Feb 16 '19 19:02 stevecondylios

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?

fenrir-naru avatar Feb 20 '19 05:02 fenrir-naru

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 ...

stevecondylios avatar Feb 21 '19 00:02 stevecondylios

Thank you. BTW, I think "a <- 2 +2/n" is little odd, did you mean "a <- 2 +2\n"? (Is the last character 'return' ?)

fenrir-naru avatar Feb 21 '19 08:02 fenrir-naru

Yes sorry that's what I meant

stevecondylios avatar Feb 21 '19 08:02 stevecondylios

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

fenrir-naru avatar Feb 21 '19 08:02 fenrir-naru

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

stevecondylios avatar Feb 21 '19 08:02 stevecondylios

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.

fenrir-naru avatar Feb 21 '19 08:02 fenrir-naru

Oh, awesome.

Out of curiosity, why not make a PR upstream if you've improved the functionality etc?

stevecondylios avatar Feb 21 '19 08:02 stevecondylios

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.

fenrir-naru avatar Feb 21 '19 09:02 fenrir-naru

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

stevecondylios avatar Feb 21 '19 13:02 stevecondylios

@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 avatar Feb 21 '19 13:02 stevecondylios

@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.

fenrir-naru avatar Feb 22 '19 00:02 fenrir-naru

Ok, I will check @fenrir-naru branch to update head branch.

clbustos avatar Feb 22 '19 04:02 clbustos

@fenrir-naru, which branch should I review? dev or multibyte?

clbustos avatar Feb 22 '19 04:02 clbustos