- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有多个 CSV 文件要读取。我希望一次处理一个文件。而不是读取所有记录直到达到提交级别。
我已经整理了一个使用分区的作业,但在运行该作业时,我发现每行都有两个条目。就好像作业运行了两次一样。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.2.xsd">
<import resource="classpath:/database.xml" />
<bean id="asyncTaskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" >
<property name="concurrencyLimit" value="1"></property>
</bean>
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" />
</bean>
<bean id="partitioner" class="org.springframework.batch.core.partition.support.MultiResourcePartitioner" scope="step">
<property name="resources" value="file:#{jobParameters[filePath]}/*.dat" />
</bean>
<bean id="multiResourceReader"
class="org.springframework.batch.item.file.MultiResourceItemReader"
scope="step">
<property name="resources" value="file:#{jobParameters[filePath]}/*.dat"></property>
<property name="delegate" ref="logItFileReader"></property>
</bean>
<batch:job id="remediationJob">
<batch:step id="partitionedStep" >
<batch:partition step="readWriteContactsPartitionedStep" partitioner="partitioner">
<batch:handler task-executor="asyncTaskExecutor" />
</batch:partition>
</batch:step>
</batch:job>
<batch:step id="readWriteContactsPartitionedStep">
<batch:tasklet>
<batch:transaction-attributes isolation="READ_UNCOMMITTED"/>
<batch:chunk reader="multiResourceReader" writer="rawItemDatabaseWriter" commit-interval="10" skip-policy="pdwUploadSkipPolicy"/>
<batch:listeners>
<batch:listener ref="customItemReaderListener"></batch:listener>
<batch:listener ref="csvLineSkipListener"></batch:listener>
<batch:listener ref="getCurrentResourceChunkListener"></batch:listener>
</batch:listeners>
</batch:tasklet>
</batch:step>
<bean id="logItFileReader" class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
<!-- Read a csv file -->
<property name="strict" value="false"></property>
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<!-- split it -->
<property name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="delimiter" value="@##@" />
<property name="strict" value="true" />
</bean>
</property>
<property name="fieldSetMapper">
<!-- map to an object -->
<bean class="org.kp.oppr.remediation.batch.vo.CSVDataVOFieldMapper">
</bean>
</property>
</bean>
</property>
</bean>
<bean id="rawItemDatabaseWriter" class="org.kp.oppr.remediation.batch.csv.RawItemDatabaseWriter"
scope="step">
</bean>
<bean id="pdwUploadSkipPolicy"
class="org.springframework.batch.core.step.skip.AlwaysSkipItemSkipPolicy" />
<bean id="csvDataVO" class="org.kp.oppr.remediation.batch.vo.CSVDataVO"
scope="prototype"></bean>
<!-- BATCH LISTENERS -->
<bean id="pdwFileMoverListener"
class="org.kp.oppr.remediation.batch.listener.PdwFileMoverListener"
scope="step">
</bean>
<bean id="csvLineSkipListener"
class="org.kp.oppr.remediation.batch.listener.CSVLineSkipListener"
scope="step">
</bean>
<bean id="customItemReaderListener"
class="org.kp.oppr.remediation.batch.listener.CustomItemReaderListener"></bean>
<bean id="getCurrentResourceChunkListener"
class="org.kp.oppr.remediation.batch.listener.GetCurrentResourceChunkListener">
<property name="proxy" ref ="multiResourceReader" />
</bean>
<!--
<bean id="stepListener" class="org.kp.oppr.remediation.batch.listener.ExampleStepExecutionListener">
<property name="resources" ref="multiResourceReader"/>
</bean>
-->
<!-- Skip Policies -->
</beans>
我在这里缺少什么吗?
最佳答案
您有 2 个问题
1 - “我希望一次处理一个文件。而不是读取所有记录直到达到提交级别。” 将 Commit-Interval 设置为 1 - 它将读取一个项目,对其进行处理,然后编写器将等待,直到有 1 个项目要写入。
2 - 就好像作业运行了两次。
看起来它会运行与您拥有的文件数量一样多的次数。
此步骤不应使用 MultiResourceItemReader。 分区器将资源分割成多个并创建单独的执行上下文。由于设置了资源属性,您的 MultiResourceItemReader 再次考虑所有文件。
关于java - Spring Batch 划分一个步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31174211/
我是在项目中使用 keras 的新手。我一直在我的模型中使用generator。 我真的很困惑我应该输入什么值 1) In fit_generator : steps_per_epoch & vali
假设我们有如下情况: A has to give $10 to B. B has to give $20 to C. C has to give $10 to D. 现在这种情况可以简化为: A lo
我正在尝试对特定列(在工作表“OA”中)进行相对引用,我需要在 110 的步骤中检索新工作表中的单元格内容 例如, =OA!$AB217 =OA!$AB327 =OA!$AB437 与其在每个单元格中
我的 PowerShell 控制台启动时间很慢(总是等待超过 5 秒),并且希望获得有关故障排除步骤的建议,以找出瓶颈可能在哪里? 我已经阅读了关于运行脚本的内容,-NoProfile防止模块等加载很
我在 NativeScript 应用程序中使用 slider 小部件,我想知道是否有步骤属性。在我的例子中,小部件代表金钱,我希望以 5 美元的增量滑动。 我查看了文档,但找不到任何对这种情况有帮助的
我在 NativeScript 应用程序中使用 slider 小部件,我想知道是否有步骤属性。在我的例子中,小部件代表金钱,我希望以 5 美元的增量滑动。 我查看了文档,但找不到任何对这种情况有帮助的
这是我的code : &n
为什么 (2) c.ERR(模棱两可)?第一个方法参数 - char ('a') 被扩展为 float => 匹配。 如果找到匹配项,是否无需继续执行第 2 步(装箱/拆箱)或第 3 步(尝试可变参数
我有一个函数,它处理一个包含 6100 个列表项的列表。当列表只有 300 个项目时,该代码可以正常工作。但是立即与 6100 崩溃。有没有一种方法可以遍历这 6100 个项目,一次说 30 个,然后
1.制作PHP安装程序的原理 其实PHP程序的安装原理无非就是将数据库结构和内容导入到相应的数据库中,从这个过程中重新配置连接数据库的参数和文件,为了保证不被别人恶意使用安装文件,当安装
我创建了一个类似于 primeNG page 的步骤组件我想把他放在一个 dynamic dialog 里面但在应用它之后,“第 1 步”和“第 2 步”不会呈现。 查看代码,我发现关键部分是我们打开
我在理解描述的 MixColumns 步骤时遇到问题 here . 我知道扩散,这一切都是有道理的,因为它指出每列都被视为多项式并乘以 GF(2^8) 的模。 但是..乘以GF(2 ^ 8)。尽管域仍
根据我对 TeamCity 工作原理的观察,我注意到在所有步骤执行完毕后评估构建失败条件。这很烦人,因为如果满足任何构建失败条件,我不能有一个不会执行的步骤。 我不是指常见的构建失败条件,例如“至少一
基于这篇试图在我的环境中测试管道代码的帖子。但它给出了以下错误消息。如何修复他的管道代码? ERROR: Unable to find project for artifact copy: test
我参与了一个项目,需要向我的一位同事提供生产数据的子集(日期范围),以进行故障排除。我想将经过清理的生产数据子集插入新的数据库表中我的同事可以访问。请提出实现此目标的最佳方法。 最佳答案 最简单的方法
我有这样的场景: 鉴于我去这个页面 当我输入 cucumber 时 然后我点击 然后我应该看到文字 我不应该看到这条线 如果我运行这个场景,它将执行所有 5 个步骤。但是我想跳过第4步(然后我应该看到
是否有任何功能可以避免 m 文件的绘图输出? 我的意思是我在文件的开头放置了一个函数(如 clc),然后所有绘图函数都被阻止。 最佳答案 您可以使用自己的(嵌套在您的函数内或同一目录中)重载内置绘图函
我是小 cucumber 语言的新手,这在我看来是非常基本的问题,但我找不到答案。 我知道可以在 Gherking 中编写多行步骤参数,如下所示: Given a blog post named "R
即使其中一个步骤失败,有没有办法继续执行 Cucumber Steps。在我当前的设置中,当一个步骤失败时, cucumber 会跳过剩余的步骤......我想知道是否有某种方法可以设置 cucumb
start-step-stop 码是一种数据压缩技术,用于压缩相对较小的数字。 该代码的工作原理如下:它具有三个参数,start、step 和 stop。 Start 确定用于计算前几个数字的位数。
我是一名优秀的程序员,十分优秀!