我正在使用带有 Intel Xeon 处理器和 24 GB RAM 的 64 位 Windows Server 2008 机器。我在尝试读取 11 GB(>2400 万行,20 列)的特定 TSV(制表符分隔)文件时遇到问题。我通常的伙伴,,read.table
让我失望了。我目前正在尝试ff
通过以下程序打包:
> df <- read.delim.ffdf(file = "data.tsv",
+ header = TRUE,
+ VERBOSE = TRUE,
+ first.rows = 1e3,
+ next.rows = 1e6,
+ na.strings = c("", NA),
+ colClasses = c("NUMERO_PROCESSO" = "factor"))
这适用于大约 600 万条记录,但随后出现错误,如您所见:
read.table.ffdf 1..1000 (1000) csv-read=0.14sec ffdf-write=0.2sec
read.table.ffdf 1001..1001000 (1000000) csv-read=240.92sec ffdf-write=67.32sec
read.table.ffdf 1001001..2001000 (1000000) csv-read=179.15sec ffdf-write=94.13sec
read.table.ffdf 2001001..3001000 (1000000) csv-read=792.36sec ffdf-write=68.89sec
read.table.ffdf 3001001..4001000 (1000000) csv-read=192.57sec ffdf-write=83.26sec
read.table.ffdf 4001001..5001000 (1000000) csv-read=187.23sec ffdf-write=78.45sec
read.table.ffdf 5001001..6001000 (1000000) csv-read=193.91sec ffdf-write=94.01sec
read.table.ffdf 6001001..
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
could not allocate memory (2048 Mb) in C function 'R_AllocStringBuffer'
如果我没记错的话,R 抱怨缺乏内存来读取数据,但是在读取数据read...ffdf
时,程序不应该避免大量内存使用吗?我在这里做错了什么?