Coder Social home page Coder Social logo

filespilt-demo's Issues

发现两个问题

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 回丢失。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.