daoqidelv / filespilt-demo Goto Github PK
View Code? Open in Web Editor NEWinit project
init project
MutilThreadReadMaster不能保证严格的按行分割吧
文件过大(几十G)时会不会造成内存泄漏?
NormalPoolMaster 这个线程池 在分割文件的时候有两个小问题
1.在计算缓存大小的时候,最后满足分割条件的时候 丢掉最后一行数据
public FileWriteTask spilt(String lineContent) {
int totalSize = this.fileCacheSize + lineContent.length();
//当前行加入后,缓存的文件内容大于上限值,则生成一个新的Task
if(totalSize >= subFileSizeLimit) {
this.subFileCounter++;
String subFileName = genSubFileName();
List fileCacheCopy = new ArrayList();
fileCacheCopy.addAll(this.fileCache);
// 这里应该加入 start
this.fileCache.add(lineContent);
//end
FileWriteTask fileWriteTask = new FileWriteTask(this.fileDir, subFileName, fileCacheCopy, this.fileCacheSize);
//重置文件缓存和大小
this.fileCache.clear();
this.fileCacheSize = 0;
return fileWriteTask;
} else {
this.fileCache.add(lineContent);
this.fileCacheSize += lineContent.length();
return null;
}
}
2.在分割完成后,丢失最后一个不足缓存大小的数据。比如 :206M 文件,10M 分割,最后6M 回丢失。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.