Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4634

most efficient way to write data into a file

$
0
0

I want to write 2TB data into one file, in the future it might be a petabyte.

The data is composed of all '1'. For example, 2TB data consisting of "1111111111111......11111" (each byte is represented by '1').

Following is my way:

File.open("data",File::RDWR||File::CREAT) do |file|  2*1024*1024*1024*1024.times do  file.write('1')  endend

That means, File.write is called 2TB times. From the point of Ruby, is there a better way to implement it?


Viewing all articles
Browse latest Browse all 4634

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>