我正在尝试在redis数据库中加载csv文件(此文件有2700万行),但它引发了'redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out'
我的代码:
Jedis jedis = new Jedis();
try {
BufferedReader in = new BufferedReader(new FileReader(fileName));
String line = in.readLine();
int i =0;
while (line != null) {
try{
String[] edgeDescription = line.split("\\s");
if (edgeDescription.length >=0) {
jedis.hset( String.valueOf(i) ,edgeDescription[0],edgeDescription[1]);
}
i++;
}
catch (OutOfMemoryError e)
{
e.getMessage();
}
line = in.readLine();
}
} catch (Exception e) {
e.printStackTrace();
}
答案 0 :(得分:2)
鉴于这组信息,很难回答这个问题。虽然我会尝试给你一些检查点:
localhost:6379
?redis-cli -h host -p port monitor
命令?一个小小的评论:你的代码通常效率不高,你应该使用管道和处理写入1000块左右的块,这样会快得多。你有没有考虑过这个?