本文是对Redis 单节点,针对不同的数据类型,做插入行测试. 数据总条数为:10058624
环境说明:
Redis 未做任何优化, 单节点 (服务器上, 内存64G).
数据量 : 10058624条 (大约一千零6万条数据,本地机器运行读取插入操作.)
数据大小 : 1093.56MB (1.1G)
插入数据类型为 String 类型
Jedis插入
public voidsave(){//连接本地Redis服务
Jedis jedis = new Jedis("bj-rack001-hadoop006");
InputStream fis= null;
fis= new BufferedInputStream(newFileInputStream(PATH));//根据数据流初始化一个DBFReader实例,用来读取DBF文件信息
DBFReader reader = newDBFReader(fis);
Object[] rowValues;int index = 0;while ((rowValues = reader.nextRecord()) != null){if (null != rowValues && rowValues.length > 0) {
index++;if (index %10000 == 0) {long end =System.currentTimeMillis();
System.out.println("处理数据中 ==> 插入数据总条数 : "+index+" 总耗时 : "+ (end-start)/1000 + " s , 处理速度 : " +(index/((end-start)/1000))+" 条 / s");
}
jedis.set("index" + SEPARATOR +index, Array2String(rowValues));
}
}
jedis.close();
}
假设插入速度为 2800条/s , 那么插入10058624 条数据需要用时: 3593秒 . ( 59.88 min , 约 1小时. )!!!!!
Pipelining插入
public voidsave(){//连接本地Redis服务
Jedis jedis = new Jedis("bj-rack001-hadoop006");
Pipeline pipelined=jedis.pipelined();
InputStream fis= null;
fis= new BufferedInputStream(newF