Using SystemCommandTasklet for split the large flat file into small files

天大地大妈咪最大 提交于 2021-02-08 10:07:20

问题


Is anyone already splitted the large flat files into small files using Spring Batch SystemCommandTasklet.

And i would like to know is it really time consuming process?

We would like to split the file with 100 million records(each record contains 15 fields).

Please any help on this would be really appreciated.

Regards

Shankar


回答1:


I do it in my talk JSR-352, Spring Batch, and You (https://www.youtube.com/watch?v=yKs4yPs-5yU). There, I use the SystemCommandTasklet in combination with OS X's split command. You can see the example configuration in the repository for that talk here: https://github.com/mminella/jsr352-springbatch-and-you.

The specific example would be as follows:

<bean id="fileSplittingTasklet" class="org.springframework.batch.core.step.tasklet.SystemCommandTasklet" scope="step">
    <property name="command" value="split -a 5 -l 10000 #{jobParameters['inputFile']} #{jobParameters['stagingDirectory']}"/>
    <property name="timeout" value="60000"/>
    <property name="workingDirectory" value="/tmp/jsr_temp"/>
</bean>

This is the preferred approach for splitting a file. The file system/OS level tools are much faster than piping the file through the java process.



来源:https://stackoverflow.com/questions/27725053/using-systemcommandtasklet-for-split-the-large-flat-file-into-small-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!